const ProjectRequest = require("../project/project_request.js");
const Url = require("../utils/url.js");

function provinceList(callback){
  const url = "/position/province/list"
  ProjectRequest.getRequest(url, callback);
}

function cityList(provinceId, callback) {
  const url = "/position/" + provinceId +"city/list"
  ProjectRequest.getRequest(url, callback);
}

function townList(cityId, productId, callback) {
  productId = null === productId ? '' : productId;
  const url = "/position/" + cityId + "town/list?productId=" + productId;
  ProjectRequest.getRequest(url, callback);
}

function search(params, callback) {
  const URL = Url.newInstance("/position/search");
  // URL.setPara('startPage', startPage)
  for (let param of params) {
    URL.addPara('params', param)
  }
  //
  ProjectRequest.getRequest(URL.get(), callback);
}

/**
 * exports
 */
module.exports = {
  provinceList: provinceList,
  cityList: cityList,
  townList: townList,
  search: search
};